package research.entity;


public class Entity {
	protected long id;
	protected EntityType type;
	
	public static Entity NULL_ENTITY = new Entity(null);

	public Entity(EntityType type) {
		this.type = type;
		id = -1;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (super.equals(obj))
			return true;
		
		if (obj instanceof Entity) {
			Entity entity = (Entity) obj;
			return entity.getType() == this.getType() && entity.getId() == this.getId() && entity.getId() >= 0;
		}
		
		return false;
	}
	
	@Override
	public String toString() {
		return this.equals(NULL_ENTITY) ? "" : this.getDisplayName();
	}
	
	public EntityType getType() {
		return type;
	}
	
	public String getTypeName() {
		return type.getName();
	}

	public String getDisplayName() {
		return this.getTypeName() + " #" + this.getId();
	}
}
